package com.example.demo.common;

import com.alibaba.fastjson2.JSON;

/**
 * 结果统一返回类
 *
 * @author xiaobeibei@gogpay.cn
 * @date 2023-12-08 11:56
 */
public class ResultDTO {

    /**
     * 状态码
     */
    private Integer status;

    /**
     * 返回信息
     */
    private String msg;

    /**
     * 返回数据
     */
    private Object data;

    public static ResultDTO success() {
        return new ResultDTO(200, "操作成功");
    }

    public static ResultDTO success(Object data) {
        return new ResultDTO(200, "操作成功", data);
    }

    public ResultDTO(Integer status, String msg) {
        this.status = status;
        this.msg = msg;
    }

    public ResultDTO(Integer status, String msg, Object data) {
        this.status = status;
        this.msg = msg;
        this.data = data;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return JSON.toJSONString(this);
    }
}
